package com.bitbakery.plugin.cl;

import com.bitbakery.plugin.cl.lang.CLFileType;
import com.bitbakery.plugin.cl.navigation.CLClassChooser;
import com.bitbakery.plugin.cl.navigation.CLSymbolChooser;
import com.intellij.navigation.ChooseByNameRegistry;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.ApplicationComponent;
import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.openapi.options.colors.ColorSettingsPages;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;

public class CLSupportLoader implements ApplicationComponent {
    private static final String[] FILE_EXTENSIONS = new String[]{"cl", "lisp"};

    public void initComponent() {
        ApplicationManager.getApplication().runWriteAction(
                new Runnable() {
                    public void run() {
                        FileTypeManager.getInstance().registerFileType(CLFileType.COMMON_LISP, FILE_EXTENSIONS);
                        ColorSettingsPages.getInstance().registerPage(new CLColorsPage());
                    }
                });

        // TODO - Is the right place for this guy??
        ChooseByNameRegistry.getInstance().contributeToClasses(new CLClassChooser());
        ChooseByNameRegistry.getInstance().contributeToSymbols(new CLSymbolChooser());
    }

    @NotNull
    @NonNls
    public String getComponentName() {
        return "Common Lisp support loader";
    }


    public void disposeComponent() {
    }
}
